//
//  GangcaiChangeAlert.m
//  兼职页面
//
//  Created by kuiyuan liang on 2021/5/27.
//

#import "GangcaiChangeAlert.h"
#import "CommonUtil.h"

@interface GangcaiChangeAlert()

@property (strong, nonatomic) UIButton * btn1;
@property (strong, nonatomic) UIButton * btn2;
@end

@implementation GangcaiChangeAlert

-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self addSubview:self.whiteView];
        [self.whiteView addSubview:self.btn1];
        [self.whiteView addSubview:self.btn2];
        self.whiteView.layer.cornerRadius = AD(10);
        self.whiteView.clipsToBounds = YES;
    }
    return self;
}

-(void)show{
    
    
    self.whiteView.frame = CGRectMake(0, kNavBarAndStatusBarHeight, SCREEN_WIDTH, AD(100));

    
    
}


-(void)setCurrentTitle:(NSString *)currentTitle{
    _currentTitle = currentTitle;
    if ([currentTitle isEqualToString:self.btn1.titleLabel.text]) {
        self.btn1.selected = YES;
        self.btn2.selected = false;
    }else if ([currentTitle isEqualToString:self.btn2.titleLabel.text]) {
        self.btn2.selected = YES;
        self.btn1.selected = false;
    }
}

- (void)btn1Click:(UIButton *)sender{
    self.btn1.selected = YES;
    self.btn2.selected = false;
    if (self.actionBlock) {
        self.actionBlock(sender.titleLabel.text);
    }
    [self dismiss];
}
- (void)btn2Click:(UIButton *)sender{
    self.btn2.selected = YES;
    self.btn1.selected = false;
    if (self.actionBlock) {
        self.actionBlock(sender.titleLabel.text);
    }
    [self dismiss];
}

-(UIButton *)btn1{
    if (!_btn1) {
        _btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
        [_btn1 addTarget:self action:@selector(btn1Click:) forControlEvents:UIControlEventTouchUpInside];
        [_btn1 setTitle:@"港彩名人堂" forState:UIControlStateNormal];
        [_btn1 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [_btn1 setTitleColor:RGB(255.0, 95.0, 125.0) forState:UIControlStateSelected];
        _btn1.frame = CGRectMake(0, 0, SCREEN_WIDTH, AD(50));
        _btn1.selected = YES;
    }
    return _btn1;
}

-(UIButton *)btn2{
    if (!_btn2) {
        _btn2 = [UIButton buttonWithType:UIButtonTypeCustom];
        [_btn2 addTarget:self action:@selector(btn2Click:) forControlEvents:UIControlEventTouchUpInside];
        [_btn2 setTitle:@"澳彩名人堂" forState:UIControlStateNormal];
        [_btn2 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [_btn2 setTitleColor:RGB(255.0, 95.0, 125.0) forState:UIControlStateSelected];
        _btn2.frame = CGRectMake(0, AD(50), SCREEN_WIDTH, AD(50));
    }
    return _btn2;
}


@end
